package org.dtrd.modules.shop.entity.po;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;

import java.util.Date;

import lombok.Data;
import org.dtrd.config.pay.PayConstant.OrderStatus;
import org.dtrd.config.pay.PayConstant.PayStatus;
import org.dtrd.modules.shop.entity.bean.OrderDetail;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;


/**
 * <p>
 * 订单记录表
 * </p>
 *
 * @author xiao
 * @since 2022-06-06
 */
@Data
@TableName("dtrd_ent_shc_rd_order")
public class DtrdEntShcRdOrder {

    /**
     * 订单ID
     */
    @TableId(value = "data_id", type = IdType.ASSIGN_UUID)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private String dataId;

    @TableField("is_del")
    @TableLogic
    private Integer isDel;

    /**
     * 下单时间
     */
    @TableField("create_time")
    private Date createTime;

    /**
     * 用户ID
     */
    @TableField("order_info_userid")
    private Integer orderInfoUserid;

    /**
     * 订单标题
     */
    @TableField("order_info_title")
    private String orderInfoTitle;

    /**
     * 订单编号，供前端展示
     */
    @TableField("order_info_no")
    private String orderInfoNo;

    /**
     * 订单总金额，单位分
     */
    @TableField("order_info_sum")
    private Long orderInfoSum;

    /**
     * 订单实际支付金额，单位分
     */
    @TableField("order_info_payment")
    private Integer orderInfoPayment;

    /**
     * 支付状态 0 未支付，1已支付
     */
    @TableField("order_info_paystatus")
    private Integer orderInfoPaystatus;

    /**
     * 订单状态，1 待支付 2 已取消 3 已支付 4 已完成
     */
    @TableField("order_info_orderstatus")
    private Integer orderInfoOrderstatus;

    /**
     * 支付时间
     */
    @TableField("pay_time")
    private Date payTime;

    /**
     * 完成时间
     */
    @TableField("complete_time")
    private Date completeTime;

    /**
     * 订单类型，0-商城订单,1-医生服务-图文咨询,2-医生服务-电话咨询,3-医生服务-预约服务,4-医生服务-控糖服务
     */
    @TableField("order_info_type")
    private Integer orderInfoType;

    /**
     * 关联服务包ID
     */
    @TableField("order_info_service_id")
    private Integer orderInfoServiceId;

    /**
     * 订单微信公众号二维码
     */
    @TableField("order_info_qrcode")
    private String orderInfoQrcode;

    /**
     * 订单微信公众号二维码result
     */
    @TableField("order_info_qrcode_result")
    private String orderInfoQrcodeResult;

    /**
     * 支付方式 1支付宝 2 微信支付 3 现金支付
     */
    @TableField("order_info_pay_type")
    private Integer orderInfoPayType;

    /**
     * 第三方支付订单号
     */
    @TableField("transaction_id")
    private String transactionId;

    /**
     * 订单备注
     */
    @TableField("remark")
    private String remark;

    /**
     * 配送方式：1-线下领取，2-配送到家
     */
    @TableField("order_info_delivery_type")
    private Integer orderInfoDeliveryType;

    /**
     * 购买方式：1-购买新机、2-以旧换新
     */
    @TableField("order_info_buy_type")
    private Integer orderInfoBuyType;

    /**
     * 机构
     */
    @TableField("org_code")
    private String orgCode;

    /**
     * 商品分类
     */
    @TableField("order_info_product_category")
    private Integer orderInfoProductCategory;
    public DtrdEntShcRdOrder init() {
        isDel = 0;
        createTime = new Date();
        orderInfoPaystatus = PayStatus.TO_BE_PAYED.getState();
        orderInfoOrderstatus = OrderStatus.TO_BE_PAYED.getState();
        return this;
    }

    public DtrdEntShcRdOrder parseFromDto(OrderDetail dto) {
//        dataId = dto.getDataId();
//        orderInfoUserid = dto.getOrderInfoUserid();
//        orderInfoNo = dto.getOrderInfoNo();
//        orderInfoSum = dto.getOrderInfoSum();
//        orderInfoPayment = dto.getOrderInfoPayment();
//        orderInfoPaystatus = dto.getOrderInfoPaystatus();
//        orderInfoOrderstatus = dto.getOrderInfoOrderstatus();
//        payTime = dto.getPayTime();
//        orderInfoType = dto.getOrderInfoType();
//        orderInfoServiceId = dto.getOrderInfoServiceId();
//        orderInfoPayType = dto.getOrderInfoPayType();
//        remark = dto.getRemark();
//        orgCode = dto.getOrgCode();
//        orderInfoProductCategory = dto.getOrderInfoProductCategory();
        dataId = dto.getDataId();
        orderInfoUserid = dto.getOrderInfoUserid();
        orderInfoTitle = dto.getOrderInfoTitle();
        orderInfoNo = dto.getOrderInfoNo();
        orderInfoSum = dto.getOrderInfoSum();
        orderInfoPayment = dto.getOrderInfoPayment();
        orderInfoPaystatus = dto.getOrderInfoPaystatus();
        orderInfoOrderstatus = dto.getOrderInfoOrderstatus();
        payTime = dto.getPayTime();
        completeTime = dto.getCompleteTime();
        orderInfoType = dto.getOrderInfoType();
        orderInfoServiceId = dto.getOrderInfoServiceId();
        orderInfoQrcode = dto.getOrderInfoQrcode();
        orderInfoQrcodeResult = dto.getOrderInfoQrcodeResult();
        orderInfoPayType = dto.getOrderInfoPayType();
        transactionId = dto.getTransactionId();
        remark = dto.getRemark();
        orderInfoDeliveryType = dto.getOrderInfoDeliveryType();
        orderInfoBuyType = dto.getOrderInfoBuyType();
        orgCode = dto.getOrgCode();
        orderInfoProductCategory = dto.getOrderInfoProductCategory();
        return this;
    }


}
